package com.aaa.system.controller.api;

import com.aaa.entity.OperLog;
import com.aaa.security.annotation.MyLog;
import com.aaa.system.service.OperLogService;
import com.aaa.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author JYH
 * @version 1.0
 * @date 2023/2/28 9:56
 */
@Api(value = "/system/api/operLog", tags = {"api操作日志"})
@RestController
@RequestMapping("/system/api/operLog")
public class ApiOperLogController {

    @Autowired
    private OperLogService operLogService;

    /**
     *
     * @author JYH
     * @date 2023/2/28 10:07
     * @description 分页查询所有操作日志
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "currentPage", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "string", name = "title", value = "", required = true)
    })
    @ApiOperation(value = "分页查询所有操作日志", notes = "分页查询所有操作日志", httpMethod = "POST")
    @PostMapping("/findAll")
    @MyLog(title = "查看操作日志")
    public Result findAll(Integer currentPage, Integer pageSize, String title){
        return operLogService.findAll(currentPage,pageSize,title);
    }

    /**
     *
     * @author JYH
     * @date 2023/2/28 11:19
     * @description 添加操作日志
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "OperLog", name = "operLog", value = "", required = true)
    })
    @ApiOperation(value = "添加操作日志", notes = "添加操作日志", httpMethod = "POST")
    @MyLog(title="添加操作日志")
    @PostMapping("/addOperLog")
    public Result addOperLog(@RequestBody OperLog operLog){
        return operLogService.addOperLog(operLog);
    }
}
